home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / oop55.zip / POINTS.PAS < prev    next >
Pascal/Delphi Source File  |  1989-05-02  |  2KB  |  88 lines

  1.  
  2. { Turbo Points }
  3. { Copyright (c) 1989 by Borland Interational, Inc. }
  4.  
  5. unit Points;
  6. { From P-20 of the Object-Oriented Programming Guide.
  7. }
  8.  
  9. interface
  10.  
  11. uses Graph;
  12.  
  13. type
  14.   Location = object
  15.     X,Y : Integer;
  16.     procedure Init(InitX, InitY : Integer);
  17.     function GetX : Integer;
  18.     function GetY : Integer;
  19.   end;
  20.  
  21.   Point = object (Location)
  22.     Visible : Boolean;
  23.     procedure Init(InitX, InitY : Integer);
  24.     procedure Show;
  25.     procedure Hide;
  26.     function IsVisible : Boolean;
  27.     procedure MoveTo(NewX, NewY : Integer);
  28.   end;
  29.  
  30. implementation
  31.  
  32. {--------------------------------------------------------}
  33. { Location's method implementations:                     }
  34. {--------------------------------------------------------}
  35.  
  36. procedure Location.Init(InitX, InitY : Integer);
  37. begin
  38.   X := InitX;
  39.   Y := InitY;
  40. end;
  41.  
  42. function Location.GetX : Integer;
  43. begin
  44.   GetX := X;
  45. end;
  46.  
  47. function Location.GetY : Integer;
  48. begin
  49.   GetY := Y;
  50. end;
  51.  
  52.  
  53. {--------------------------------------------------------}
  54. { Points's method implementations:                       }
  55. {--------------------------------------------------------}
  56.  
  57. procedure Point.Init(InitX, InitY : Integer);
  58. begin
  59.   Location.Init(InitX, InitY);
  60.   Visible := False;
  61. end;
  62.  
  63. procedure Point.Show;
  64. begin
  65.   Visible := True;
  66.   PutPixel(X, Y, GetColor);
  67. end;
  68.  
  69. procedure Point.Hide;
  70. begin
  71.   Visible := False;
  72.   PutPixel(X, Y, GetBkColor);
  73. end;
  74.  
  75. function Point.IsVisible : Boolean;
  76. begin
  77.   IsVisible := Visible;
  78. end;
  79.  
  80. procedure Point.MoveTo(NewX, NewY : Integer);
  81. begin
  82.   Hide;
  83.   Location.Init(NewX, NewY);
  84.   Show;
  85. end;
  86.  
  87. end.
  88.